package dao_manager;

import java.util.List;

import org.hibernate.Query;

import beans.HistoriqueFields;
import dao_hibernate.GenericDAOImpl;
import dao_hibernate.GenericDao;
import dao_hibernate.HibernateUtil;

public class HistoriqueFieldsManagerImpl implements HistoriqueFieldsManager{
    
    private GenericDao<HistoriqueFields, Long> historiqueFieldDao=new GenericDAOImpl<HistoriqueFields, Long>() {};
    
    @Override
    public void saveHistoriqueFields( HistoriqueFields hF ) {
        try {
            HibernateUtil.beginTransaction();
            historiqueFieldDao.save(hF);
            HibernateUtil.commitTransaction();
        } catch (Exception ex) {
            ex.printStackTrace();
            HibernateUtil.rollback();
        }
        HibernateUtil.closing();
    }

    @Override
    public List<HistoriqueFields> getHistorique( long ClientID ) {
        
        List<HistoriqueFields> l=null;
        
        
        try {
            HibernateUtil.beginTransaction();
            Query query = HibernateUtil.getSession().getNamedQuery("getHistorique");
            query.setLong( 0, ClientID );
            l= historiqueFieldDao.findMany( query );
            HibernateUtil.commitTransaction();
        } catch (Exception ex) {
            ex.printStackTrace();
            HibernateUtil.rollback();
        }
        HibernateUtil.closing();
        return l;
    }
    
   
        
    }


